package fileexercise;

import java.io.File;
import java.io.FileFilter;

//2. Test02.java：将当前项目目录下1.txt-100.txt文件删除
public class Test02 {
    public static void main(String[] args) {
        File dir = new File(".");
        if (dir.isDirectory()){
            FileFilter filter =new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name = file.getName();
                    return name.endsWith(".txt") ;
                }
            };
            File[] subs = dir.listFiles(filter);
            for (File sub : subs){
                sub.delete();
            }
        }
    }
}
